<?php
/**
 * 获取配置参数
 *
 * 
 */
 
use Workerman\Worker;
use Workerman\Mysql;
require_once( __DIR__ .'/conf.php');
class get_conf{
    static $folder_name_conf;
    static $page_conf;
    static $module_title_conf;
    static $icon_conf;

    public function entry($param){
        return $this->do_get_conf($param);
    }

    public static function init($g_folder_name_conf,$g_page_conf,$g_module_title_conf,$g_icon_conf){
        self::$folder_name_conf = $g_folder_name_conf;
        self::$page_conf = $g_page_conf;
        self::$module_title_conf = $g_module_title_conf;
        self::$icon_conf = $g_icon_conf;
    }

    /** 
    * do_get_conf  
    * 获取批次等级分布
    * 
    * @access private 
    * @param $param batch
    * @since 1.0 
    * @return array(errcode,errmsg,rtv) 
    */
    private function do_get_conf($param){
        $action = $param["action"];
        $obj ="";

        $action = $_POST["action"];

        if($action==="get_authority"){
            $id = $_POST["id"];
            $sql = "select authority,authority_class from hf_mes_groups where id='$id'";
            $ret = sql_fetchall($sql);
            $obj = $ret;
        }

        if($action==="get_modules_conf"){
            $rt = (object)[
                "folder_name_conf" => self::$folder_name_conf,
                "page_conf" => self::$page_conf,
                "module_title_conf" => self::$module_title_conf,
                "icon_conf" => self::$icon_conf
            ];

            $obj = $rt;
        }
        return array("errcode"=> 0,"errmsg"=>"","rtval"=>$obj);
    }
     
    /** 
    * create  
    * 通过 call_user_func 获得本class的实例
    * 
    * @access public 
    * @since 1.0 
    * @return object 本类的实例
    */  
    public static function create(){  
        static $instance;
        if (!$instance){  
            $instance = new get_conf();  
        }
        return $instance;  
    }   
 }
 
get_conf::init($folder_name_conf,$page_conf,$module_title_conf,$icon_conf);
